import cfg from '../../config';
import {getView} from '../../util/api';
import {Slider, sliderHide, sliderShow} from '../../lib/kslider';
import {formatDate, getCurrDay, randomColor, isArrContain, isArrNoContain, findStr, backPage} from '../../util/aid';
import {loadJingTinInfoFun} from '../common';

import Dialog from '../../lib/kdialog';
const dialog = new Dialog();

const $ = require('../../lib/kdom');
let _view = require('raw-loader!./order-query.html');

export default class {
  path = '/train/order-query$';
  hash = '/train/order-query';
  title = '订单查询';

  constructor(opt) {
    opt = opt || {};
    this.path = opt.path || this.path;
    this.hash = opt.hash || this.hash;
    this.title = opt.title || this.title;
  }

  // 输出视图
  view(cb) {
    if (!_view) {
      // 静态资源浏览器有缓存,增加时标,强制刷新!
      getView(`${cfg.train.view.orderQuery}?t=${(+new Date())}`, '', (rs) => {
        _view = rs;
        cb(null, _view);
      });
    } else
      cb(null, _view);
  }

  // 在已经加载的视图上操作
  bind(dv, params) {
    let jingTinInfo = {
      "successcode": "T",
      "data": {
        "TrainInfo": {
          "Train": {"FromStation": "合肥", "ToStation": "北京", "FromTime": "18:40", "ArriveTime": "05:56", "TrainNo": "T64", "FullTrainNo": "T64", "TradeGrade": "特快", "BeginStation": "合肥", "EndStation": "北京", "Seconds": "40560", "Duration": "11时16分", "Dist": "1109", "Seats": {"SeatInfo": [{"SeatCode": "405", "SeatName": "高级软卧上", "SeatPrice": "745.5"}, {"SeatCode": "406", "SeatName": "高级软卧下", "SeatPrice": "745.5"}, {"SeatCode": "101", "SeatName": "硬座", "SeatPrice": "141.5"}, {"SeatCode": "301", "SeatName": "硬卧上", "SeatPrice": "261.5"}, {"SeatCode": "302", "SeatName": "硬卧中", "SeatPrice": "261.5"}, {"SeatCode": "303", "SeatName": "硬卧下", "SeatPrice": "261.5"}, {"SeatCode": "401", "SeatName": "软卧上", "SeatPrice": "426.5"}, {"SeatCode": "402", "SeatName": "软卧下", "SeatPrice": "426.5"}]}},
          "Stations": {
            "StationInfo": [{"StationName": "蚌埠", "ArriveTime": "20:25", "DepartTime": "20:29", "StayMinutes": "4", "DurationMinutes": "105", "Kms": "131", "Seats": {"SeatInfo": [{"SeatCode": "101", "SeatName": "硬座", "SeatPrice": "21.5"}, {"SeatCode": "301", "SeatName": "硬卧上", "SeatPrice": "112.5"}, {"SeatCode": "302", "SeatName": "硬卧中", "SeatPrice": "112.5"}, {"SeatCode": "303", "SeatName": "硬卧下", "SeatPrice": "112.5"}, {"SeatCode": "401", "SeatName": "软卧上", "SeatPrice": "147.5"}, {"SeatCode": "402", "SeatName": "软卧下", "SeatPrice": "147.5"}, {"SeatCode": "405", "SeatName": "高级软卧上", "SeatPrice": "227.5"}, {"SeatCode": "406", "SeatName": "高级软卧下", "SeatPrice": "227.5"}]}}, {
              "StationName": "宿州",
              "ArriveTime": "21:17",
              "DepartTime": "21:20",
              "StayMinutes": "3",
              "DurationMinutes": "157",
              "Kms": "221",
              "Seats": {"SeatInfo": [{"SeatCode": "101", "SeatName": "硬座", "SeatPrice": "37.5"}, {"SeatCode": "301", "SeatName": "硬卧上", "SeatPrice": "128.5"}, {"SeatCode": "302", "SeatName": "硬卧中", "SeatPrice": "128.5"}, {"SeatCode": "303", "SeatName": "硬卧下", "SeatPrice": "128.5"}, {"SeatCode": "401", "SeatName": "软卧上", "SeatPrice": "170.5"}, {"SeatCode": "402", "SeatName": "软卧下", "SeatPrice": "170.5"}, {"SeatCode": "405", "SeatName": "高级软卧上", "SeatPrice": "264.5"}, {"SeatCode": "406", "SeatName": "高级软卧下", "SeatPrice": "264.5"}]}
            }, {"StationName": "徐州", "ArriveTime": "22:05", "DepartTime": "22:16", "StayMinutes": "11", "DurationMinutes": "205", "Kms": "295", "Seats": {"SeatInfo": [{"SeatCode": "101", "SeatName": "硬座", "SeatPrice": "43.5"}, {"SeatCode": "301", "SeatName": "硬卧上", "SeatPrice": "134.5"}, {"SeatCode": "302", "SeatName": "硬卧中", "SeatPrice": "134.5"}, {"SeatCode": "303", "SeatName": "硬卧下", "SeatPrice": "134.5"}, {"SeatCode": "401", "SeatName": "软卧上", "SeatPrice": "180.5"}, {"SeatCode": "402", "SeatName": "软卧下", "SeatPrice": "180.5"}, {"SeatCode": "405", "SeatName": "高级软卧上", "SeatPrice": "283.5"}, {"SeatCode": "406", "SeatName": "高级软卧下", "SeatPrice": "283.5"}]}}, {
              "StationName": "天津西",
              "ArriveTime": "04:21",
              "DepartTime": "04:31",
              "StayMinutes": "10",
              "DurationMinutes": "581",
              "Kms": "961",
              "Seats": {"SeatInfo": [{"SeatCode": "101", "SeatName": "硬座", "SeatPrice": "124"}, {"SeatCode": "405", "SeatName": "高级软卧上", "SeatPrice": "663"}, {"SeatCode": "406", "SeatName": "高级软卧下", "SeatPrice": "663"}, {"SeatCode": "301", "SeatName": "硬卧上", "SeatPrice": "230"}, {"SeatCode": "302", "SeatName": "硬卧中", "SeatPrice": "230"}, {"SeatCode": "303", "SeatName": "硬卧下", "SeatPrice": "230"}, {"SeatCode": "401", "SeatName": "软卧上", "SeatPrice": "381"}, {"SeatCode": "402", "SeatName": "软卧下", "SeatPrice": "381"}]}
            }, {"StationName": "北京", "ArriveTime": "05:56", "DepartTime": null, "StayMinutes": null, "DurationMinutes": "676", "Kms": "1109", "Seats": {"SeatInfo": [{"SeatCode": "405", "SeatName": "高级软卧上", "SeatPrice": "745.5"}, {"SeatCode": "406", "SeatName": "高级软卧下", "SeatPrice": "745.5"}, {"SeatCode": "101", "SeatName": "硬座", "SeatPrice": "141.5"}, {"SeatCode": "301", "SeatName": "硬卧上", "SeatPrice": "261.5"}, {"SeatCode": "302", "SeatName": "硬卧中", "SeatPrice": "261.5"}, {"SeatCode": "303", "SeatName": "硬卧下", "SeatPrice": "261.5"}, {"SeatCode": "401", "SeatName": "软卧上", "SeatPrice": "426.5"}, {"SeatCode": "402", "SeatName": "软卧下", "SeatPrice": "426.5"}]}}]
          }
        }
      }
    };

    $.qu('#pg-train-order-query .jt-info').onclick = () => {
      loadJingTinInfoFun(jingTinInfo);
      sliderShow();
    };


    // backPage
    // backPage('#pg-train-order-query', 'backPage', () => {
    //   $.router.go('/train/user', '', true);
    // });
  }

  /*bind*/
}

